﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Library.WebControls.SimplePaging {
	public sealed class RightCellPaging : TableCell {
		public RightCellPaging() {
			HorizontalAlign = HorizontalAlign.Right;
			CssClass = "right-cell-paging";
		}
		[DefaultValue("right-cell-paging")]
		public override string CssClass {
			get {
				return base.CssClass;
			}
			set {
				base.CssClass = value;
			}
		}
		[DefaultValue(HorizontalAlign.Right)]
		public override HorizontalAlign HorizontalAlign {
			get {
				return base.HorizontalAlign;
			}
			set {
				base.HorizontalAlign = value;
			}
		}
		protected override void CreateChildControls() {
			_show = new Label();// { Text = "View" };
			Controls.Add(_show);
			Controls.Add(CreateSpaceText());
			_startPage = new ZeroLable { Text = "0" };
			Controls.Add(_startPage);
			Controls.Add(CreateSpaceText());
			_spliter = new SpliterLable { Text = "-" };
			Controls.Add(_spliter);
			Controls.Add(CreateSpaceText());
			_endPage = new ZeroLable { Text = "0" };
			Controls.Add(_endPage);
			Controls.Add(CreateSpaceText());
			_of = new Label();// { Text = "of" };
			Controls.Add(_of);
			Controls.Add(CreateSpaceText());
			_totalIems = new ZeroLable { Text = "0" };
			Controls.Add(_totalIems);
		}
		private static HtmlGenericControl CreateSpaceText() {
			return new HtmlGenericControl("span") { InnerText = " " };
		}
		private Label _show;
		private Label _startPage;
		private Label _spliter;
		private Label _endPage;
		private Label _of;
		private Label _totalIems;

		public Label Show {
			get { EnsureChildControls(); return _show; }
		}

		public Label StartPage {
			get { EnsureChildControls(); return _startPage; }
		}

		public Label Spliter {
			get { EnsureChildControls(); return _spliter; }
		}

		public Label EndPage {
			get { EnsureChildControls(); return _endPage; }
		}

		public Label Of {
			get { EnsureChildControls(); return _of; }
		}

		public Label TotalIems {
			get { EnsureChildControls(); return _totalIems; }
		}

		private class SpliterLable : System.Web.UI.WebControls.Label {
			[DefaultValue("-")]
			public override string Text {
				get {
					return base.Text;
				}
				set {
					base.Text = value;
				}
			}
		}
	}
}
